|
|
|
|
|
|
|
Add the possibility of user errors and database errors, and you have a good bit of responsibility! And you haven't even seen what you need to do to add a new record to the table or delete an existing one. You also need a way for the user to browse the data. Remember that dropping the data control means your form does not automatically display the VCR-style navigation arrows. |
|
|
|
|
|
|
|
|
Despite this added responsibility, writing your data entry forms with Visual Basic code gives you much greater control over the process and can result in a form that is easy for both programmers and users to deal with. Even though you have to do a good bit of coding to create new data management routines, you can place most of this new code in an OLE Server DLL that can be reused in future projects with a minimum amount of coding. |
|
|
|
|
|
|
|
|
Before you create the generic data entry routines, you need to examine an important topic, record searching. Up until now, we have only touched on this issue. You can use one of several methods to search for a record in a Recordset; some are faster than others. Using the most effective method in your Visual Basic programs can make your programs seem fast and solid. Using an ineffective search method can make your program seem slow. |
|
|
|
|
|
|
|
|
The Visual Basic data-access object interface is a set-oriented interface. It is designed and tuned to quickly return a set of multiple records that meet your search criteria. However, a major part of data entry processing involves key-oriented searches. These are searches for a single, specific record that needs to be updated. Visual Basic offers the following three different approaches to handling key-oriented searches: |
|
|
|
|
|
|
|
|
· The Move methods: You can use these methods to browse records one by one (commonly called "walking the dataset"). The Move methods allow you to use Visual Basic code to move from one record to the next in the dataset. |
|
|
|
|
|
|
|
|
· The Seek method: You can use this method to perform an indexed search of the dataset to find the first record that meets your criteria. This search method is the fastest one provided by Visual Basic, and it can only be applied to Recordsets that are opened tables. Dynasets and Snapshots cannot use the Seek method. |
|
|
|
|
|
|
|
|
· The Find methods: You can use these methods to locate a single record in the dataset that meets a set of criteria you establish. This criteria is similar to the SQL WHERE clause you learned about in Day 8, "Selecting Data with SQL." The Find methods perform a sequential search of the dataset to locate the first record that meets your criteria. |
|
|
|
|
|